<h4><i class="fa fa-stack-overflow"></i> <?php echo Yii::t('helpdesk','Documents'); ?></h4><hr>
<?php $this->renderPartial('/site/documents/search', array('keyword' => isset($keyword)?$keyword:null));?>
<div class="content">
    <?php $this->renderPartial('/site/documents/sidebar', array('arrFolders' => $arrFolders, 'cateId' => $cateId));?>
    <div class="main-panel col-md-9">
       <?php $this->renderPartial('/site/documents/breadcrumb', array('cate' => $cate, 'keyword' => $keyword, 'post' => $post));?>    	
        <!-- Title -->
    	<h4><?php echo $post['post_title']; ?></h4>
        <!-- Content -->
        <div><?php echo $post['post_body']; ?></div>  
        
	<?php if(isset($post['fields']['article-attachment'])): ?>
        <!-- Attachment -->
        <!-- Preview -->
        <?php $ext = strtolower(pathinfo($post['fields']['article-attachment'], PATHINFO_EXTENSION)); ?>
		<?php if(in_array($ext, array('pdf', 'doc', 'docx', 'xls', 'xlsx'))): ?>
        <div class="preview"><iframe src="https://docs.google.com/viewer?url=<?php echo urlencode(UPLOADS_URL.'/'.$post['fields']['article-attachment']); ?>&embedded=true" width="100%" height="450px"></iframe></div>
     	<?php elseif(in_array($ext, array('png', 'jpg', 'jpeg', 'gif'))): ?>
        <div class="preview"><img src="<?php echo UPLOADS_URL.'/'.$post['fields']['article-attachment']; ?>"></div>
        <?php elseif(in_array($ext, array('mp3', 'wav', 'ogg'))): ?>
        <audio controls>
            <source src="<?php echo UPLOADS_URL.'/'.$post['fields']['article-attachment']; ?>" type="<?php if($ext == 'ogg'):?>audio/ogg<?php else: ?>audio/mpeg<?php endif; ?>">
        </audio> 
        <?php endif; ?>
        
        <?php if($post['post_privacy'] == '2' && !empty($urlDownload)): ?>
        <!-- Download -->
        <div><?php echo Yii::t('helpdesk','Download'); ?>: <?php echo '<a href="javascript:__download(\''.$tokenDownload.'\');" title="Download">'.pathinfo($post['fields']['article-attachment'], PATHINFO_BASENAME).'</a>' ?></div>  
    	<?php endif; ?>
	<?php endif; ?>
    </div>
</div>